/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kphoto.mc.logic;

import java.sql.ResultSet;
import kphoto.mc.databaseHandler.DatabaseHandler;

/**
 *
 * @author AndreasK
 */
public class Contact {
    
    private String contactId;
    private String company;
    private String firstName;
    private String lastName;
    private String address;
    private String zipCode;
    private String city;
    private String fonBusiness;
    private String fonMobile;
    private String fonPrivate;
    private String fax;
    private String email;
    private String webSite;

    public String getAddress() {
        return address;
    }

    public String getCity() {
        return city;
    }

    public String getZipAndCity() {
        return zipCode + " " + city;
    }
    
    public String getFullName(){
        return firstName + " " + lastName;
    }

    public String getCompany() {
        return company;
    }
    
    /*
     * Creates a string containing all relevant fields for 
     * the address field used in a letter or invoice.
     */
    public String GetAddressFields(){
        StringBuilder stringBuilder = new StringBuilder();
        if(company != null){
            stringBuilder.append(company).append("\n");
        }
        if(firstName != null && lastName != null){
            stringBuilder.append(firstName).append(" ").append(lastName).append("\n");
        }
        stringBuilder.append(address).append("\n\n");
        
        stringBuilder.append(getZipAndCity());
        
        return stringBuilder.toString();
    }
    
    public Contact(String contID) throws Exception{
        contactId = contID;
        GetContactFromDatabase();
    }

    private void GetContactFromDatabase() throws Exception {
        ResultSet resultSet = DatabaseHandler.ExecuteSqlQuery("SELECT * FROM contacts WHERE contactId = 'XYZ'");
    }
    
    
}
